<?php session_start();
error_reporting(E_ALL);
if(!isset($_SESSION['loggin']))
{
	die('You did not login, Please login first!');
}
?>
<html><!-- InstanceBegin template="/Templates/template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>DrinkDelivery</title>
<!-- InstanceEndEditable -->
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="login">
<img src="image/logo.jpg" width="100" height="30" align="middle">
 <p> <font size="+2" color="#FFFFFF"><a href="CU.html">                                           Contact Us</a></font></p>
<a href="logout.php"><img src="image/logout.png" align="right"></a>
<a href="login.php"><img src="image/login.png" align="right"></a> 
</div>
<div id="header">
<ul>
  <li></li>
<li><a href="store.php"><img src="image/m2.jpg" width="200" height="200"></a></li>
<li><a href="member.php"><img src="image/m3.jpg" width="200" height="200"></a></li>
<li><a href="category.php"><img src="image/m4.jpg" width="200" height="200"></a></li>
</ul>
</div>
<br/>
<div id="content">
<!-- InstanceBeginEditable name="content" -->
<div id="member">
 <h1 align="center">Have a nice day<br />
   <?php echo "<strong>".$_SESSION['username']."</strong>"; ?>!</h1>
<p>
  <?php if($_SESSION['username']=="admin")
  {?>
  <table border="1" cellpadding="10px" cellspacing="0" align="center">
    <tr>
    <th>ID</th>
    <th>Name</th>
    <th>Feedback</th>
    <th>Date</th>
    </tr>
    <?php
	  $connection = mysql_connect("localhost", "root", "");
		if ( !$connection ) {
			die('Could not connect to localhost.');	
		}
		
		$db = mysql_select_db("test", $connection);
		if ( !$db) {
			die ('Could not find database test.');	
		}
		$result = mysql_query('SELECT * FROM feedback', $connection);	
		
		while ($row = mysql_fetch_array($result)) {
			echo "<tr>";
			echo "<td>" . $row['id'] . "</td>";
			echo "<td>" . $row['name'] . "</td>";
			echo "<td>" . $row['feedback'] . "</td>";
			echo "<td>" . $row['date'] . "</td>";			
			echo "</tr>";										
		}
		mysql_free_result($result);		
		
		if(isset($_REQUEST['submit']))
		{
			$dl = "DELETE FROM feedback WHERE id='".$_POST['del']."'"; 
			mysql_query($dl,$connection);
			?>
            <br>
            <?php
		}
		
		mysql_close($connection);	
		?>
  </table>
  <p>
  </p>
  <form action="feedback.php" method="post">
<table border="1"  cellpadding="10px" cellspacing="0" align="center">
    <tr>
    <th>Please Enter the deleted Bill ID:</th>
    <td>
    <input type="text" name="del" size="9" /> 
    </td>
    <td><input type="submit" name="submit" value="Delete" />
    </td>
    <td>
    <a href="feedback.php">
    <input type="button" value="Fresh"></a>
    </tr>
</table>
</form>
  <?php
  
  }
  
  else{
	  	$connection = mysql_connect("localhost", "root", "");
		if ( !$connection ) {
			die('Could not connect to localhost.');	
		}
		
		$db = mysql_select_db("test", $connection);
		if ( !$db) {
			die ('Could not find database test.');	
		}
		
		if ( isset($_REQUEST['submit'])) {
	$feed=$_GET['feedback'];	
	$name=$_SESSION['username'];
	$r = "insert into feedback (name,feedback, date) values('" . $name . "','" . $feed . "',NOW())";
	
	$in = mysql_query($r,$connection);
	if (!$in)
 	 {
  		die('Error: ' . mysql_error());
 	 }
	}										
    ?>
	</p>
    <form action="feedback.php" method="get">  
    <table border="1" cellpadding="10px" cellspacing="0" align="center">
    <tr>
    <th>Feedback</th>
    <td>
    <input type="text" name="feedback" size"80" /> </td>
    <td>
    <input type="submit" name="submit" value="Submit" />
    <input type="button" value="reset"/>
    </td></tr>
    </table>
    </form>
    <?php
    }?>
</div>
<div id="memberfunction">
<img src="id/xiaohei.jpg" width="300"
height="300">
<br/><a href="bill.php"><img src="image/bill.jpg" width="100" height="50" align="middle"></a>
<a href="change.php"><img src="image/change.jpg" width="100" height="50" align="right"></a>
<br /><a href="chart.php"><img src="image/chat.jpg" width="100" height="50" align="middle"></a>
<a href="member.php"><img src="image/detail.jpg" width="100" height="50" align="right"></a>
</div>
<!-- InstanceEndEditable -->
</div>
<a href="index.php">z</a> </div>
</body>
<!-- InstanceEnd --></html>
